package com.lvmama.dashboard.service.ssh.impl;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lvmama.dashboard.dao.ssh.IShellTaskDao;
import com.lvmama.dashboard.entity.ShellTask;
import com.lvmama.dashboard.exception.ServiceException;
import com.lvmama.dashboard.service.ssh.IShellTaskService;
import com.lvmama.dashboard.utils.ErrDict;

@Service
public class ShellTaskServiceImpl implements IShellTaskService {
	
	@Autowired
	private IShellTaskDao shellTaskDao;
	
	@Override
	public ShellTask queryByTashName(String taskName) {
		if(StringUtils.isBlank(taskName)) {
			throw new ServiceException(ErrDict.SHELL.SHEEL_NAME_CANT_BE_NULL.getMsg());
		}
		ShellTask sellTask = shellTaskDao.queryByTashName(taskName);
		if(sellTask == null) {
			throw new ServiceException(ErrDict.SHELL.NOT_EXIST_JOB_NAME.getMsg());
		}
		return sellTask;
	}

}
